//****************************************************
// Porman Project 2
// Filename: CBufferObject.h
// Date: 2009/03/21
// Author: KengYu Lin
// Modify:
//****************************************************
#ifndef _CBUFFEROBJECT_H
#define _CBUFFEROBJECT_H
#include "CBaseObject.h"

namespace Porman
{

namespace GL
{

class CBufferObject : public CBaseObject
{
    friend class CRenderDevice;
public:
    PGL_API virtual void setName( const char* pName ) { m_sName = std::string("BufObj_") + std::string( pName ); }

    PGL_API void changeTarget( EBufferTarget enumTarget );
    PGL_API EBufferTarget getTarget( void ) { return m_eTarget; }
    PGL_API ERESULT setData( int iOffset, int iSize, const void* pData );
    PGL_API ERESULT getData( int iOffset, int iSize, void* pData );

protected:
    CBufferObject( CRenderDevice* pDevice, EBufferTarget enumTarget, int iSizeInByte, EBufferUsage enumUsage );
    virtual ~CBufferObject( void );

    ERESULT _lock( EBufferAccess enumAccess, int iOffset, void** ppData );
    ERESULT _unlock( void );

protected:
    unsigned int       m_uiObjID;
    EBufferTarget      m_eTarget;
    EBufferUsage       m_eUsage;
    int                m_iSizeInBytes;
};

}//End namespace GL

}//End namespace Porman

#endif